'use strict'

const _ = require('lodash')
const { Controller } = require('egg')

class Test extends Controller {
  async test() {
    const { ctx } = this
    const { action } = ctx.params
    const fnName = _.camelCase(action)

    if (this[fnName]) return await this[fnName]()
  }

  async data() {
    const { ctx } = this
    const { query } = ctx

    const returnData = await Promise.all([
      // this.service.trackData.placeType()
      // this.service.trackData.homeInfo(),
      // this.service.trackData.personEnterByScope('month'),
      // this.service.trackData.codeInfo(),
      // this.service.trackData.placeTypeScanByScope('month'),
      // this.service.trackData.hsInfo(),
      // this.service.trackData.personCategory(),
      // this.service.trackData.townHsResultByScope('month'),
      // this.service.trackData.reportInfo(),
      // this.service.trackData.townHsCollect(),
      // this.service.trackData.townPerson(),
      // this.service.trackData.townScanByScope('month'),
      // this.service.trackData.townPersonEnterByScope('month'),
      // this.service.trackData.personFromCityByScope('month'),
      // this.service.trackData.syncFxyr(),
      // this.service.trackData.getFxryScanData(),
      // this.service.trackData.fxryPlaceScanByScope('month'),
      // this.service.trackData.getFxryHsData(),
      // this.service.trackData.hsyj(),
      // this.service.trackData.townSpecialPerson(),
      // this.service.trackData.fxyj(),
      // this.service.trackData.getFxryHsData(),
      this.service.trackData.reportByScope('month'),
      // this.service.trackData.syncZdry(),
      // this.service.trackData.getZdryHsData(),

      // this.service.trackData.personEnterByScope('month'),
    ])

    ctx.body = {
      code: 0,
      msg: 'success',
      data: returnData,
    }
  }

  async dayTask() {
    const { ctx } = this
    const { query } = ctx

    this.service.task.dayTask()

    ctx.body = {
      code: 0,
      msg: 'success',
    }
  }

  async trackData() {
    const { ctx } = this
    const { query } = ctx

    const returnData = await ctx.model.TrackData.find()
    ctx.body = {
      code: 0,
      msg: 'success',
      data: returnData,
    }
  }
}

module.exports = Test
